package cz.muni.fi.pa165.sme.services.converter;

import cz.muni.fi.pa165.sme.api.to.BurnedCaloriesTO;
import cz.muni.fi.pa165.sme.dao.entity.BurnedCalories;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.convert.converter.Converter;

/**
 * @author Amruz
 */
public class BurnedCalories2BurnedCaloriesTOConverter implements
		Converter<BurnedCalories, BurnedCaloriesTO> {

	@Autowired
	private SportActivity2SportActivityTOConverter sportActivityTOConverter;

	@Override
	public BurnedCaloriesTO convert(final BurnedCalories source) {
		if (source == null) {
			return null;
		}

		final BurnedCaloriesTO target = new BurnedCaloriesTO();

		target.setId(source.getId());
		target.setSportActivity(sportActivityTOConverter.convert(source.getSportActivity()));
		target.setCalories(source.getCalories());
		target.setSpeed(source.getSpeed());
		target.setWeight(source.getWeight());

		return target;
	}
}
